package com.example.mapper;


import com.example.bean.Address;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface AddressMapper {

    //查询所有
    @Select("select *from address where u_id=#{uId}")
    List<Address> findAll(int uId);
    //修改
    @Update("update address set r_name=#{rName},r_phone=#{rPhone},r_address=#{rAddress} where a_id=#{aId}")
    Boolean updateAddress(int aId, String rName, String rPhone, String rAddress);
    //增加
    @Insert("insert into address (u_id,r_name,r_phone,r_address) values(#{uId},#{rName},#{rPhone},#{rAddress})")
    int AddAddress(int uId,String rName, String rPhone, String rAddress );
    //删除
    @Delete("delete from address where a_id=#{aId}")
    Boolean deleteAddress(int aId);
    //查询默认地址
    @Select("select * from address where u_id=#{uid} limit 0,1")
    Address findDefaultAddress(int uid);
}
